package com.example.backgroundtask;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.ac_main_thread_btn).setOnClickListener(this);
        findViewById(R.id.ac_main_thread_lifecycle).setOnClickListener(this);
        findViewById(R.id.ac_main_thread_concurrent_safety).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ac_main_thread_btn:
                goThreadActivity();
                break;
            case R.id.ac_main_thread_lifecycle:
                goThreadLifcycleActivity();
                break;
            case R.id.ac_main_thread_concurrent_safety:
                goConcurrentSafetyActivity();
                break;
        }
    }

    private void goThreadActivity() {
        Intent intent = new Intent(this, ThreadActivity.class);
        startActivity(intent);
    }

    private void goThreadLifcycleActivity() {
        Intent intent = new Intent(this, ThreadLifeCycleActivity.class);
        startActivity(intent);
    }

    private void goConcurrentSafetyActivity() {
        Intent intent = new Intent(this, ConcurrentSafetyActivity.class);
        startActivity(intent);
    }
}